package com.novellotus.httploadingview;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;


/**
 * Created by：Rich on 2017/5/10
 */
public class LoadingDialog extends Dialog {

    private View mDialogView;
    private boolean mCloseFromCancel;
    public TextView mLoadingTv;
    public String mLoadingText = "加载中...";

    public LoadingDialog(Context context) {
        super(context, R.style.alert_dialog);
        //默认返回键可以取消
        setCancelable(true);
        //其他区域不可取消
        setCanceledOnTouchOutside(true);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loading_view);
        //mDialogView = getWindow().getDecorView().findViewById(android.R.id.content);
        mLoadingTv = findViewById(R.id.loading_text);
       // mLoadingTv.setText(mLoadingText);
    }

    @Override
    protected void onStart() {
        //   mDialogView.startAnimation(mModalInAnim);
    }

    @Override
    public void cancel() {
        dismissWithAnimation(true);
    }

    private void dismissWithAnimation(boolean fromCancel) {
        mCloseFromCancel = fromCancel;
        LoadingDialog.super.dismiss();
        // mDialogView.startAnimation(mModalOutAnim);
    }

    /**
     * 设置加载中文字
     * @param loadingText
     */
//    public void setLoadingText(String loadingText) {
//        if(!TextUtils.isEmpty(loadingText)){
//            mLoadingTv.setText(loadingText);
//        }
//    }
}
